package com.ruoyi.offer.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.offer.domain.HrOfferFollowup;
import com.ruoyi.offer.service.IHrOfferFollowupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * offer跟进Controller
 * 
 * @author gy
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/offer/followup")
public class HrOfferFollowupController extends BaseController
{
    @Autowired
    private IHrOfferFollowupService hrOfferFollowupService;

    /**
     * 查询offer跟进列表
     */
    @PreAuthorize("@ss.hasPermi('offer:followup:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrOfferFollowup hrOfferFollowup)
    {
        startPage();
        List<HrOfferFollowup> list = hrOfferFollowupService.selectHrOfferFollowupList(hrOfferFollowup);
        return getDataTable(list);
    }

    /**
     * 导出offer跟进列表
     */
    @PreAuthorize("@ss.hasPermi('offer:followup:export')")
    @Log(title = "offer跟进", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrOfferFollowup hrOfferFollowup)
    {
        List<HrOfferFollowup> list = hrOfferFollowupService.selectHrOfferFollowupList(hrOfferFollowup);
        ExcelUtil<HrOfferFollowup> util = new ExcelUtil<HrOfferFollowup>(HrOfferFollowup.class);
        util.exportExcel(response, list, "offer跟进数据");
    }

    /**
     * 获取offer跟进详细信息
     */
    @PreAuthorize("@ss.hasPermi('offer:followup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hrOfferFollowupService.selectHrOfferFollowupById(id));
    }

    /**
     * 新增offer跟进
     */
    @PreAuthorize("@ss.hasPermi('offer:followup:add')")
    @Log(title = "offer跟进", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrOfferFollowup hrOfferFollowup)
    {
        return toAjax(hrOfferFollowupService.insertHrOfferFollowup(hrOfferFollowup));
    }

    /**
     * 修改offer跟进
     */
    @PreAuthorize("@ss.hasPermi('offer:followup:edit')")
    @Log(title = "offer跟进", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrOfferFollowup hrOfferFollowup)
    {
        return toAjax(hrOfferFollowupService.updateHrOfferFollowup(hrOfferFollowup));
    }

    /**
     * 删除offer跟进
     */
    @PreAuthorize("@ss.hasPermi('offer:followup:remove')")
    @Log(title = "offer跟进", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hrOfferFollowupService.deleteHrOfferFollowupByIds(ids));
    }
}
